package com.atguigu.process.service.impl;

import com.atguigu.auth.service.SysUserService;
import com.atguigu.model.process.ProcessRecord;
import com.atguigu.model.system.SysUser;
import com.atguigu.process.mapper.ProcessRecordMapper;
import com.atguigu.process.service.ProcessRecordService;
import com.atguigu.security.custom.LoginUserInfoHelper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class ProcessRecordServiceImpl extends ServiceImpl<ProcessRecordMapper,
        ProcessRecord> implements ProcessRecordService {
    @Autowired
    private SysUserService userService;

    @Override
    public void record(Long processId, Integer status, String description) {
        SysUser user = userService.getById(LoginUserInfoHelper.getUserId());
        ProcessRecord record = new ProcessRecord();
        record.setProcessId(processId);
        record.setStatus(status);
        record.setDescription(description);
        record.setOperateUser(user.getName());
        record.setOperateUserId(LoginUserInfoHelper.getUserId());
        save(record);
    }
}
